package java实验五;

public class 程序二 {
	
	public static void main(String [] args)
	{
		int [] a = {1,2};
		System.out.println("交换前两个数是"+a[0]+","+a[1]);
		
		swap1(a[0],a[1]);
		System.out.println("交换前两个数是"+a[0]+","+a[1]);
		System.out.println("交换前两个数是"+a[0]+","+a[1]);
		swap2(a);
		System.out.println("交换前两个数是"+a[0]+","+a[1]);
	}

public static void swap1(int a,int b)
{
	int t=a;
	a=b;
	b=t;
	
}
public static void swap2(int []a)
{
	int t=a[0];
	a[0]=a[1];
	a[1]=t;
	
}}